import request from '@/utils/request.js'

export function apiUserLogin ({ mobile, code }) {
  return request({
    url: '/app/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}

export function apiUserFollow (target) {
  return request({
    url: '/app/v1_0/user/followings',
    method: 'post',
    data: {
      target
    }
  })
}

export function apiUserUnfollow (target) {
  return request({
    url: '/app/v1_0/user/followings/' + target,
    method: 'delete'
  })
}

export const apiUserInfo = () => {
  return request({
    url: '/app/v1_0/user',
    method: 'GET'
  })
}

export function apiUserProfile () {
  return request({
    url: '/app/v1_0/user/profile',
    method: 'get'
  })
}

export function apiUserPhoto (fdObj) {
  return request({
    url: '/app/v1_0/user/photo',
    method: 'patch',
    data: fdObj
  })
}

export function apiSaveProfile ({ name, gender, birthday }) {
  return request({
    url: '/app/v1_0/user/profile',
    data: {
      name,
      gender,
      birthday
    },
    method: 'patch'
  })
}
